package com.nacrtstudio.webgiftshop.pages;

import java.util.Set;

import javax.annotation.PropertyKey;

import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.InjectComponent;
import org.apache.tapestry5.annotations.InjectPage;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.corelib.components.Form;
import org.apache.tapestry5.corelib.components.TextField;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.Request;
import org.openqa.selenium.ie.IeReturnTypes;

import com.nacrtstudio.webgiftshop.facade.Controller;
import com.nacrtstudio.webgiftshop.model.shop.PackedGift;
import com.nacrtstudio.webgiftshop.util.shop.Country;
import com.nacrtstudio.webgiftshop.util.shop.SerbiaTowns;

public class CustomerDetails {
	@Inject
	private Request request;
	public void onActivate() {
		try {
			if (controller.getRequest()==null) {
	    		controller.setRequest(request);
			}
		} catch (Exception e) {
		}
	}

	@Inject
	@Property
	private Controller controller;
	@Component(id = "userInfoForm")
	private Form userInfoForm;
	@Property
	private Country country;
	@InjectPage
	private DeliveryDetails deliveryDetails;
	
	@SuppressWarnings("unchecked")
	public Object onSuccessFromUserInfoForm(){
		try {
			deliveryDetails.setPackedGifts((Set<PackedGift>) controller.packGiftsFromCart());
		} catch (Exception e) {
			System.out.println("\n\n\n"+e);
		}
		controller.updateUser(controller.getLoggedUser());
		return deliveryDetails;
	}
	
	@Property
	private SerbiaTowns town;
	
	Object onValueChanged(){
		System.out.println("testtttttttttttttttttt");
		return Contact.class;
	}
	
	
}
